<template>
	<view class="receive">
		<view class="nav">
			<u-tabs :list="list1" lineColor="#FF5B1A" :activeStyle="{color: '#FF5B1A'}" @click="change" :scrollable="false"></u-tabs>
		</view>
		<scroll-view scroll-y="true" class="main" @scrolltolower="lower()">
			<view class="list" v-for="(item,index) of list" @click="detail(item.id)">
				<view class="r">
					<image :src="oss(item.avatar)" class="cover" mode=""></image>
				</view>
				<view class="l">
					<view class="title">{{item.nickname}}</view>
					<view class="info">
						<view class="other">时间:</view>
						<view class="con">{{item.createtime | date}}</view>
					</view>
				</view>
				
			</view>
			<u-empty v-if="list.length === 0 && finish" mode="data" marginTop="100">
			</u-empty>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '一级好友',
					type: 1
				}, {
					name: '二级好友',
					type: 2
				}],
				
				page: 1,
				finish: false,
				type: 1,
				list: [],
				note: '',
				id: ''
			}
		},
		
			
		onLoad(options) {
			this.id = options.id
			this.getList()
		},
		methods: {
		
			change(e) {
				console.log(e)
				this.type = e.type
				this.reload()
			},
			reload() {
				this.page = 1
				this.finish = false
				this.list = []
				this.getList()
			},
			lower() {
				this.page++
				this.getList()
			},
			getList() {
				if (this.finish) {
					return
				}
				uni.$u.http.post('/myrec', {
					type: this.type
				}).then(res => {
					if (res.code == 1) {
						this.list = this.list.concat(res.data)
						if (res.data.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {
		
				})
			}
		}
	}
</script>

<style lang="scss">
	.receive {
		height: 100vh;
		position: relative;
		background-color: #F6F6F6;
		.nav{
			display: flex;
			align-items: center;
			justify-content: center;
			flex-shrink: 0;
		}
		.main{
			position: absolute;
			left: 0;
			width: 100%;
			bottom: 0;
			top: 90rpx;
			padding-top: 20rpx;
			overflow: hidden;
		}
		.list{
			display: flex;
			margin: 0 20rpx 10rpx;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			align-items: center;
			position: relative;
			.l{
				flex: 1;
				.title{
					color: #191615;
					font-size: 36rpx;
				}
				.info{
					display: flex;
					align-items: center;
					margin-top: 10rpx;
					.other{
						color: #999999;
						font-size: 28rpx;
						margin-right: 10rpx;
					}
					.con{
						color: #575859;
						font-size: 28rpx;
						display: flex;
						align-items: center;
						.moeny{
							color: #FF5B1A;
						}
						.num{
							color: #428DFC;
						}
					}
				}
			}
			.r{
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				margin-right: 20rpx;
				
				.cover{
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
				}
				
			}
		}
	}
</style>
